package com.survey.project.research.service.impl;

import java.util.List;

import com.survey.common.utils.DateUtils;
import com.survey.project.research.domain.vo.ConsumerInVo;
import com.survey.project.research.domain.vo.ConsumerOutVo;
import com.survey.project.research.domain.vo.QuestionnaireQuestionListOutVo;
import com.survey.project.research.domain.vo.ResearchConsumerQuestionnaireDetailOutVo;
import com.survey.project.research.mapper.QuestionnaireMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.survey.project.research.mapper.ConsumerMapper;
import com.survey.project.research.domain.Consumer;
import com.survey.project.research.service.IConsumerService;

/**
 * 客户管理Service业务层处理
 *
 * @author survey
 * @date 2021-05-20
 */
@RequiredArgsConstructor
@Service
public class ConsumerServiceImpl implements IConsumerService {

    private final ConsumerMapper consumerMapper;

    private final QuestionnaireMapper questionnaireMapper;


    /**
     * 查询客户管理
     *
     * @param consumerId 客户管理ID
     * @return 客户管理
     */
    @Override
    public ConsumerOutVo selectConsumerById(Long consumerId) {
        return consumerMapper.selectConsumerById(consumerId);
    }

    /**
     * 查询客户管理列表
     *
     * @param inVo 客户管理
     * @return 客户管理
     */
    @Override
    public List<ConsumerOutVo> selectConsumerList(ConsumerInVo inVo) {
        return consumerMapper.selectConsumerList(inVo);
    }

    /**
     * 新增客户管理
     *
     * @param consumer 客户管理
     * @return 结果
     */
    @Override
    public int insertConsumer(Consumer consumer) {
        consumer.setCreateTime(DateUtils.getNowDate());
        return consumerMapper.insertConsumer(consumer);
    }

    /**
     * 修改客户管理
     *
     * @param consumer 客户管理
     * @return 结果
     */
    @Override
    public int updateConsumer(Consumer consumer) {
        consumer.setUpdateTime(DateUtils.getNowDate());
        return consumerMapper.updateConsumer(consumer);
    }

    /**
     * 批量删除客户管理
     *
     * @param consumerIds 需要删除的客户管理ID
     * @return 结果
     */
    @Override
    public int deleteConsumerByIds(Long[] consumerIds) {
        return consumerMapper.deleteConsumerByIds(consumerIds);
    }

    /**
     * 删除客户管理信息
     *
     * @param consumerId 客户管理ID
     * @return 结果
     */
    @Override
    public int deleteConsumerById(Long consumerId) {
        return consumerMapper.deleteConsumerById(consumerId);
    }

    /**
     * 根据客户id查询问卷题目和答案
     *
     */
    @Override
    public List<ResearchConsumerQuestionnaireDetailOutVo> questionnaireDetail(Long consumerId) {
        return consumerMapper.questionnaireDetail(consumerId);
    }
}
